/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Caps
 */
@Entity
@Table(name = "questionario_has_questao")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "QuestionarioHasQuestao.findAll", query = "SELECT q FROM QuestionarioHasQuestao q"),
    @NamedQuery(name = "QuestionarioHasQuestao.findByQuestionarioIdquestionario", query = "SELECT q FROM QuestionarioHasQuestao q WHERE q.questionarioHasQuestaoPK.questionarioIdquestionario = :questionarioIdquestionario"),
    @NamedQuery(name = "QuestionarioHasQuestao.findByQuestaoIdquestao", query = "SELECT q FROM QuestionarioHasQuestao q WHERE q.questionarioHasQuestaoPK.questaoIdquestao = :questaoIdquestao")})
public class QuestionarioHasQuestao implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected QuestionarioHasQuestaoPK questionarioHasQuestaoPK;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "questionarioHasQuestao")
    private List<Resposta> respostaList;
    @JoinColumn(name = "questionario_idquestionario", referencedColumnName = "idquestionario", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Questionario questionario;
    @JoinColumn(name = "questao_idquestao", referencedColumnName = "idquestao", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Questao questao;

    public QuestionarioHasQuestao() {
    }

    public QuestionarioHasQuestao(QuestionarioHasQuestaoPK questionarioHasQuestaoPK) {
        this.questionarioHasQuestaoPK = questionarioHasQuestaoPK;
    }

    public QuestionarioHasQuestao(int questionarioIdquestionario, int questaoIdquestao) {
        this.questionarioHasQuestaoPK = new QuestionarioHasQuestaoPK(questionarioIdquestionario, questaoIdquestao);
    }

    public QuestionarioHasQuestaoPK getQuestionarioHasQuestaoPK() {
        return questionarioHasQuestaoPK;
    }

    public void setQuestionarioHasQuestaoPK(QuestionarioHasQuestaoPK questionarioHasQuestaoPK) {
        this.questionarioHasQuestaoPK = questionarioHasQuestaoPK;
    }

    @XmlTransient
    public List<Resposta> getRespostaList() {
        return respostaList;
    }

    public void setRespostaList(List<Resposta> respostaList) {
        this.respostaList = respostaList;
    }

    public Questionario getQuestionario() {
        return questionario;
    }

    public void setQuestionario(Questionario questionario) {
        this.questionario = questionario;
    }

    public Questao getQuestao() {
        return questao;
    }

    public void setQuestao(Questao questao) {
        this.questao = questao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (questionarioHasQuestaoPK != null ? questionarioHasQuestaoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof QuestionarioHasQuestao)) {
            return false;
        }
        QuestionarioHasQuestao other = (QuestionarioHasQuestao) object;
        if ((this.questionarioHasQuestaoPK == null && other.questionarioHasQuestaoPK != null) || (this.questionarioHasQuestaoPK != null && !this.questionarioHasQuestaoPK.equals(other.questionarioHasQuestaoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.QuestionarioHasQuestao[ questionarioHasQuestaoPK=" + questionarioHasQuestaoPK + " ]";
    }
    
}
